package com.itheima.config;

import com.itheima.filter.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;


    @Override

    public void addInterceptors(InterceptorRegistry registry) {

        //注册TestInterceptor拦截器

        InterceptorRegistration registration = registry.addInterceptor(loginInterceptor);

        //所有路径都被拦截

        registration.addPathPatterns("/**");

        //添加不拦截路径

        registration.excludePathPatterns("/auth/test","/auth/login", "/static/**","/auth/register","/auth/updatePassWord","/creatCode/**");

    }

}
